/* eslint-disable no-unused-vars */
/* eslint-disable no-unused-vars */
<template>
  <div class="playList-container">
    <div class="title">
      <div class="title-container">当前播放</div>
    </div>
    <!-- 列表内容 -->
    <div class="list-container"
      v-for="item in playList"
      :key="item.id">
      <!-- 列表项 -->
      <div :class="{'active':item.id==currentMusic.id}"
        @click="play(item)">{{item.name}}<span v-for="item in item.song.artists"
          :key="item.id">-{{item.name}}</span></div>
      <van-icon class="icon"
        @click="Delete(item)"
        name="cross"
        color="#fff" />
    </div>
  </div>
</template>

<script>
import { mapState, mapMutations } from 'vuex'
export default {
  name: 'PlayList',
  computed: {
    ...mapState(['playList', 'currentMusic'])
  },

  created () {
    console.log(this.playList)
  },
  methods: {
    ...mapMutations(['getCurrentMusic']),

    // 播放
    play (item) {
      this.getCurrentMusic(item)
    },
    // 删除当前音乐
    ...mapMutations(['removePlayList']),
    Delete (item) {
      console.log(item)
      this.removePlayList(item)
    }
  }
}
</script>

<style lang="less" scoped>

.playList-container{
  padding:0 10px;
  background-color: #272727;
  // height: 100vh;
  color: #fff;

  .title{
    position: sticky;
    background-color: #252525;
    top: 0;
    z-index: 3;

    .title-container{
     padding: 10px 0;
    }
  }
}
.list-container{
  // margin: 0 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 16px;
  margin: 5px;
  .active{
    color: red;
  }
  .icon{
    margin-right: 10px;
  }

}
</style>
